<?php
error_reporting(E_ALL);

date_default_timezone_set('Europe/London');

/** PHPExcel_IOFactory */
require_once '../Classes/PHPExcel/IOFactory.php';


if (!file_exists("upload/time_table.xlsx")) {
	exit("Please run 05featuredemo.php first.\n");
}

echo date('H:i:s') . " Load from Excel2007 file\n";
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel = $objReader->load("upload/time_table.xlsx");

echo date('H:i:s') . " Iterate worksheets\n";
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
	echo '- ' . $worksheet->getTitle() . "\r\n" . PHP_EOL;

	foreach ($worksheet->getRowIterator() as $row) {
		echo '    - Row number: ' . $row->getRowIndex() . "\r\n" . PHP_EOL;

		$cellIterator = $row->getCellIterator();
		$cellIterator->setIterateOnlyExistingCells(false); // Loop all cells, even if it is not set
		foreach ($cellIterator as $cell) {
			if (!is_null($cell)) {
				echo '        - Cell: ' . $cell->getCoordinate() . ' - ' . $cell->getCalculatedValue() . "\r<BR>" . PHP_EOL;
			}
		}
	}
}


// Echo memory peak usage
echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n" . PHP_EOL;

// Echo done
echo date('H:i:s') . " Done writing files.\r\n" . PHP_EOL;
/*require_once '../classes/PHPExcel/IOFactory.php';

class ExcelAnalyser {
	private $file_name = "";
	private $objReader;
	private $objPHPExcel;
	private $worksheets;
	
	
	public function _construct($file_name) {
		//would require to check if the file exists or not
		$this->file_name = $file_name;
		$this->objReader = new PHPExcel_IOFactory::createReader('Excel2007');
		$this->objPHPExcel = $this->objReader->load($file_name);
	}
	
	private function update_worksheets() {
		$this->worksheets = array();
		
		foreach ($this->objPHPExcel->getWorksheetIterator() as $worksheet)
			$this->worksheets[] = $worksheet;
			
		echo count($this->worksheets);
	}
	
	public function get_supervisor_detail() {
		$supervisor_table = array();
		
		return $supervisor_table;	
	}
	
	
}*/

?>